﻿@*@using OASystem.Models;
    @using OASystem.Model;
    @{
        Userinfo user = AdminContext.context.adminUser;
    }*@
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>培训</title>
    <link href="~/css/tail.css" rel="stylesheet" type="text/css" />
    <link href="~/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="~/js/jquery.js"></script>
    <script src="~/Scripts/jquery-3.3.1.min.js"></script>
    <script type="text/javascript" src="~/layui/layui.js"></script>
    <script src="~/js/date/js/laydate.js"></script>
    <script src="~/layui/lay/modules/layer.js"></script>
    <script src="~/js/layer_v2.1/layer/layer.js"></script>
    <script type="text/javascript" src="~/js/jquery.js"></script>
    <script>
        function change() {
            var height01 = $(window).height();
            $(".top").css('height', height01 - 35 + "px");
        }
    </script>
</head>
<style>
    span {
        color: forestgreen;
    }
</style>
<body style="border-radius: 8px" onload="change()">
    <!--<div class="title"><h2>通知详情</h2></div>-->
    <div id="form_demo">
        <div class="top">
            <div>
                <div class="top_out">
                    <table class="table">
                        <tbody>
                            <tr>
                                <td colspan="6" style="text-align: left;border-top: none"><input type="text" name="name" minlength="2" required id="userid" style="display:none"></td>
                            </tr>
                            <tr>
                                <td>原密码：</td>
                                <td colspan="3" style="text-align: left">
                                    <input type="password" class="long_text" id="oldpwd">
                                </td>
                            </tr>
                            <tr>
                                <td>修改密码：</td>
                                <td colspan="3" style="text-align: left">
                                    <input type="password" class="long_text" id="newpwd">
                                    <span id="newpwdz" style="display:block">只能输入6-20个字母、数字、下划线</span>
                                </td>
                            </tr>
                            <tr>
                                <td>确认密码：</td>
                                <td colspan="3" style="text-align: left">
                                    <input type="password" class="long_text" id="surepwd">
                                    <span id="buyiz" style="display:block">两次密码必须一致</span>
                                </td>
                            </tr>
                        </tbody>
                    </table>
                </div>
            </div>
            <div class="bot_btn">
                <input class="btn" value="修改" type="button" id="submits" />
                <button class="btn btn1"><a href="~/Home/Ahome" target="right">返回</a></button>
            </div>
        </div>
    </div>
</body>

</html>
<script>
    var a = false;
    var b = false;

    $("#submits").click(function () {
        if (a && b) {
            var pwd = $("#oldpwd").val();
            var newpwd = $("#newpwd").val();
            var surepwd = $("#surepwd").val();
            var shu = {}
            shu.Password = pwd
            $.ajax({
                url: "/Login/IndexUpdate?newpwd=" + newpwd,
                type: "Post",
                data: shu,
                success: function (operateResult) {
                    if (operateResult.Success) {
                        layer.msg('修改成功！', {
                            title: '提示框',
                            icon: 1,
                            time: 2000
                        }, function () {
                            location.reload();//刷新页面
                            layer.close(index);
                        });
                        // window.location.href = "/Home/Ahome";
                    } else {
                        layer.msg('修改失败！', {
                            title: '提示框',
                            icon: 1,
                            time: 2000
                        });
                    }
                }

            });
        }
    });
    //正则表达式
    $("#newpwd").blur(function () {
        var newpwds = $("#newpwd").val();
        var patrn = /^(\w){6,20}$/;
        if (!patrn.test(newpwds)) {
            $("#newpwdz").css("color", "red");
        } else {
            $("#newpwdz").css("color", "forestgreen");
            a = true;
        }
    })
    //判断两次密码是否一致
    $("#surepwd").blur(function () {
        var newpwds = $("#newpwd").val();
        var surepwd = $("#surepwd").val();
        if (newpwds != surepwd) {
            $("#buyiz").css("color", "red");
        } else {
            $("#buyiz").css("color", "forestgreen");
            b = true;
        }
    })
</script>
